/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:龙宝
 * Date:2023-11-26
 * Time:17:19
 */
public enum Test {
    RED,BLACK,GREEN,WHITE;
    public static void main(String[] args) {
        Test test = Test.BLACK;
        switch (test) {
            case RED:
                System.out.println("red");
                break;
            case BLACK:
                System.out.println("black");
                break;
            case WHITE:
                System.out.println("WHITE");
                break;
            case GREEN:
                System.out.println("green");
                break;
            default:
                break;
        }


        Test[] testEnum2 = Test.values();
        for (int i = 0; i < testEnum2.length; i++) {
            System.out.println(testEnum2[i] + " " + testEnum2[i].ordinal());
        }
        System.out.println("=========================");
        System.out.println(Test.valueOf("GREEN"));

        //拿到枚举实例BLACK
        Test testEnum = Test.BLACK;
        //拿到枚举实例RED
        Test testEnum21 = Test.RED;
        System.out.println(testEnum.compareTo(testEnum21));
        System.out.println(BLACK.compareTo(RED));
        System.out.println(RED.compareTo(BLACK));
    }
}
